/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "category")
public class Category extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Category";
	public static final String ALIAS_CATEGORY_ID = "categoryId";
	public static final String ALIAS_CATEGORY_NAME = "categoryName";
	public static final String ALIAS_LEVEL = "level";
	public static final String ALIAS_TYPE = "type";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * categoryId       db_column: categoryId 
     */ 	
	
	private java.lang.Long categoryId;
    /**
     * categoryName       db_column: categoryName 
     */ 	
	@NotBlank @Length(max=50)
	private java.lang.String categoryName;
    /**
     * level       db_column: level 
     */ 	
	
	private java.lang.Integer level;
    /**
     * type       db_column: type 
     */ 	
	
	private java.lang.Integer type;
	//columns END


	public Category(){
	}

	public Category(
		java.lang.Long categoryId
	){
		this.categoryId = categoryId;
	}

	

	public void setCategoryId(java.lang.Long value) {
		this.categoryId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "categoryId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getCategoryId() {
		return this.categoryId;
	}
	
	@Column(name = "categoryName", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
	public java.lang.String getCategoryName() {
		return this.categoryName;
	}
	
	public void setCategoryName(java.lang.String value) {
		this.categoryName = value;
	}
	
	@Column(name = "level", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getLevel() {
		return this.level;
	}
	
	public void setLevel(java.lang.Integer value) {
		this.level = value;
	}
	
	@Column(name = "type", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getType() {
		return this.type;
	}
	
	public void setType(java.lang.Integer value) {
		this.type = value;
	}
	
	
	private Set publishInfos = new HashSet(0);
	public void setPublishInfos(Set<PublishInfo> publishInfo){
		this.publishInfos = publishInfo;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "category")
	public Set<PublishInfo> getPublishInfos() {
		return publishInfos;
	}
	
	private Set publishInfoCategorys = new HashSet(0);
	public void setPublishInfoCategorys(Set<PublishInfoCategory> publishInfoCategory){
		this.publishInfoCategorys = publishInfoCategory;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "category")
	public Set<PublishInfoCategory> getPublishInfoCategorys() {
		return publishInfoCategorys;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("CategoryId",getCategoryId())
			.append("CategoryName",getCategoryName())
			.append("Level",getLevel())
			.append("Type",getType())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getCategoryId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Category == false) return false;
		if(this == obj) return true;
		Category other = (Category)obj;
		return new EqualsBuilder()
			.append(getCategoryId(),other.getCategoryId())
			.isEquals();
	}
}

